#ifndef PSEGY_H
#define PSEGY_H
#include "database.h"
#include <QApplication>
const int IEEETYPE=2;
const int IBMTYPE=512;

typedef struct
{
    int TraceNoLine; //(4B 1-4) trace sequence number within line
    int TraceNoReel; //   - (4B 5-8) trace sequence number within reel
    int RecordNoField; //   - (4B 9-12) original field record number:
    int TraceNoField; //   - (4B 13-16) - trace number within the original field record (channel)
    int SourceNo; //   - (4B 17-20) energy source point number
    int CDPNo; //   - (4B 21-24) CDP ensemble number
    int TraceNoCDP; //   - (4B 25-28) trace number within CDP ensemble
    short TraceCode; //   - (2B 29-30) trace identification code - flag de trace (0 : KO, 1 :
    //                OK)
    short TraceNumVerSum; //   - (2B 31-32) number of vertically summed traces
    short TraceNumHorSum; //   - (2B 33-34) number of horizontally stacked traces (fold)
    short DataType; //   - (2B 35-36) data use production or test
    int DistanceStoR; //   - (4B 37-40) distance from source to receiver
    int ElevReceiver; //   - (4B 41-44) receiver group elevation
    int ElevSource; //   - (4B 45-48) surface elevation at source
    int DepthSource; //   - (4B 49-52) source depth below surface
    int ElevReceiverDatum; //   - (4B 53-56) datum elevation at receiver
    int ElevSourceDatum; //   - (4B 57-60) datum elevation at source
    int DepthSourceWater; //   - (4B 61-64) water depth at source
    int DepthReceiverWater; //   - (4B 65-68) (water depth at receiver)
    //
    short ScalerE; //   - (2B 69-70) scalar for bytes 41-68
    short ScalerC; //   - (2B 71-72) scalar for bytes 73-88
    int SourceCoordinateX; //   - (4B 73-76) Source X coordinate
    int SourceCoordinateY; //   - (4B 77-80) Source Y coordinate
    int ReceiverCoordinateX; //   - (4B 81-84) receiver X coordinate
    int ReceiverCoordinateY; //   - (4B 85-88) receiver Y coordinate
    short CoordinateUnit; //   - (2B 89-90) coordinates units - to database
    short WeatherVelocity; //   - (2B 91-92) weathering velocity
    short SubweatherVelocity; //   - (2B 93-94) sub-weathering velocity
    short UpholeTimeSource; //   - (2B 95-96) uphole time at source
    short UpholeTimeReceiver; //   - (2B 97-98) uphole time at receiver
    short StaticCorrectSource; //   - (2B 99-100) source static correction
    short StaticCorrectReceiver; //   - (2B 101-102) receiver static correction
    short TotalStatic; //   - (2B 103-104) total static applied - msec from start date ƫ
    short LagTimeA; //   - (2B 105-106) lag time A
    short LagTimeB; //   - (2B 107-108) lag time B
    short DelayTime; //   - (2B 109-110) delay recording time
    short MuteTimeStart; //   - (2B 111-112) mute time start
    short MuteTimeEnd; //   - (2B 113-114) mute time end
    short SampleNum; //   - (2B 115-116) number of samples in this trace (max 32767 if more
    //                  read(4B 229-232)
    short SampleInterval; //   - (2B 117-118) sample interval in this trace (micro second) //
    short GainType; //   - (2B 119-120) gain type of instruments
    short GainConstant; //   - (2B 121-122) instrument gain constant
    short InitalGain; //   - (2B 123-124) instrument early gain
    short Correlated; //   - (2B 125-126) correlated flag
    short SweepFreqStart; //   - (2B 127-128) sweep start frequency
    short SweepFreqEnd; //   - (2B 129-130) sweep end frequency
    short SweepLength; //   - (2B 131-132) sweep length
    short SweepType; //   - (2B 133-134) sweep type
    short SweepTaperLStart; //   - (2B 135-136) sweep start taper length
    short SweepTaperLEnd; //   - (2B 137-138) sweep end taper length
    short SweepTaperType; //   - (2B 139-140) sweep taper type
    short AliasFreq; //   - (2B 141-142) alias filter freq - to database
    short AliasSlope; //   - (2B 143-144) alias filter slope - to database
    short NotchFreq; //   - (2B 145-146) notch filter freq - to database
    short NotchSlope; //   - (2B 147-148) notch filter slope - to database
    short LowCutFreq; //   - (2B 149-150) low cut freq - to database
    short HighCutFreq; //   - (2B 151-152) high cut freq - to database
    short LowCutSlope; //   - (2B 153-154) low cut slope - to database
    short HighCutSlope; //   - (2B 155-156) high cut slope - to database
    short Year; //   - (2B 157-158) Year recorded  -
    short Day; //   - (2B 159-160) day of year recordedJulianDay .from 2008.1.1 -
    short Hour; //   - (2B 161-162) hour of day recorded -
    short Minute; //   - (2B 163-164) minute of hour recorded -
    short Second; //   - (2B 165-166) second of minute recorded -
    short TimeBasisCode; //   - (2B 167-168) time basic code
    short TraceWeightFactor; //   - (2B 169-170) trace weighting factor
    short GeophoneNoRoll; //   - (2B 171-172) geophone group number of roll switch pos 1
    short GeophoneNoFirstTrace; //   - (2B 173-174) geophone group number of trace 1 in record
    short GeophoneNoLastTrace; //   - (2B 175-176) geophone group number of last trace
    short GapSize; //   - (2B 177-178) gap size
    short Overtravel; //   - (2B 179-180) overtravel associated with taper
    short noUse1[10]; //   - (20B 181-200)
    int ndsamp; //   - (4B 201-204) ndsamp : sample step in micro second
    short format; //   - (2B 205-206) format
    short noUse2[11]; //   - (22B 207-228)
    int number2; //   - (4B 229-232) number of samples in this trace (nsamp)
    int noUse4[2]; //   - (8B 233-240)
} Psegy_trace;

class Psegy : public DataBase
{
public:
    Psegy();
    virtual ~Psegy();
    Psegy(QString fileName);
    Psegy(QString fileName,DATAFORMAT dataFormat);
    Psegy_trace *getTrace();
    int IbmToInt(const int ibm);
public:
    virtual QDateTime getStartTime();
    virtual LONG getPointNumber();
    virtual int *getData(LONG start ,LONG end,DATAFORMAT dataformat =0 ,int pianyiPoint =0 );
    virtual int getFreq();
    int getInterval();
    int getPianyi();
    virtual QVector<QPointF> get_PSegy_Data(LONG preNum, LONG lastNum);
private:
    int getTotalStaticApplied();
    Psegy_trace *trace;

};



#endif // PSEGY_H
